#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int > vec;
typedef pair < int , int > pii;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1e7 + 10;
const int mod = 1e9 + 7;

#define int long long

ll qp(ll x,int t) { ll res = 1;for(;t;t >>= 1,x = x * x % mod) if(t & 1) res = res * x % mod; return res; }

int n,f[N],s,pro;

signed main() {
#ifndef ONLINE_JUDGE
    //freopen("1.in","r",stdin);
#endif
    n = in; s = qp(2,n); pro = s - 1;
    f[0] = 0; f[1] = 0; f[2] = 0;
    for(int i = 3;i <= n;i++) {
	pro = (ll) pro * (s - i + 1) % mod; pro = (pro + mod) % mod;
	f[i] = (pro - f[i - 1] - (ll) f[i - 2] * (i - 1) % mod * (s - i + 1) % mod) % mod;
	f[i] = (f[i] + mod) % mod;
    }
    printf("%lld\n",((ll) pro * (s - n) % mod - f[n] + mod) % mod); return 0;
}
